package com.greatwqs.wmall.task.provider.controller;

import com.greatwqs.wmall.common.module.exception.AppException;
import com.greatwqs.wmall.user.client.service.ExceptionClientService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.FileNotFoundException;

/**
 * dubbo test
 * http://localhost:18099/swagger-ui/index.html
 *
 * @author wang-qingsong
 */
@Slf4j
@RestController
@RequestMapping(value = "/dubbo-test")
public class ExceptionController {

    @DubboReference
    private ExceptionClientService exceptionClientService;

    @GetMapping(value = "runtimeException")
    public String runtimeException(){
        return exceptionClientService.runtimeException();
    }

    @GetMapping(value = "illegalArgumentException")
    public String illegalArgumentException(){
        return exceptionClientService.illegalArgumentException();
    }

    @GetMapping(value = "appException")
    public String appException() throws AppException{
        return exceptionClientService.appException();
    }

    @GetMapping(value = "appExceptionNotThrowsDefine")
    public String appExceptionNotThrowsDefine(){
        return exceptionClientService.appExceptionNotThrowsDefine();
    }

    @GetMapping(value = "fileNotFoundException")
    public String fileNotFoundException() throws FileNotFoundException{
        return exceptionClientService.fileNotFoundException();
    }
}
